package com.talkweb.sendmsg.service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Service;

@Service
public class MsgConsumer {

	@Autowired
	private MsgSender msgSender;

	@JmsListener(destination = "zh-queue")
	public void sendMsg(String mobile) {

		// 调用发送短信的serviceImpl
		String result = msgSender.sendMsg(mobile);
		JSONObject jsonObject = JSON.parseObject(result);
		String reason = (String)jsonObject.get("reason");

		// 发短信逻辑
		System.out.println(reason);
	}
}
